package com.example.baiduai.ai.controller;


import com.example.baiduai.ai.dto.*;
import com.example.baiduai.ai.service.AiImageService;
import com.example.baiduai.utils.JsonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.util.List;


/**
 * 百度ai 图片的功能
 */
@RestController
@RequestMapping("/ai/images")
public class AiImagesController {

    @Autowired
    private AiImageService ailmageService;

    /**
     *  图片分组检查
     * @return
     */
    @GetMapping("/aiImagesClassify")
    public JsonResult aiImagesClassify(List<MultipartFile> files , Integer top_num){
        return ailmageService.aiImagesClassify(files,top_num);
    }



    /**
     *  创建数据集
     * @return
     */
    @PostMapping("/createDataSet")
    public JsonResult getCreateDataSet(@RequestBody CreateDataSetDto createDataSetDto){
        return ailmageService.createDataSet(createDataSetDto);
    }


    /**
     *  查看数据集列表
     * @return
     */
    @PostMapping("/dataSetList")
    public JsonResult dataSetList(@RequestBody DatasetListDto datasetListDto){
        return ailmageService.dataSetList(datasetListDto);
    }

    /**
     * 分类（标签）列表API
     */
    @PostMapping("/labeList")
    public JsonResult labeList(@RequestBody LableDto labeList){
        return ailmageService.labeList(labeList);
    }



    /**
     * 添加数据API
     */
    @PostMapping("/datasetAdd")
    public JsonResult datasetAdd(@RequestBody DatasetAdd datasetAdd){
        return ailmageService.datasetAdd(datasetAdd);
    }

    /**
     * 数据集删除API
     */
    @PostMapping("/datasetDelete")
    public JsonResult datasetDelete(@RequestBody DatasetDelete datasetDelete){
        return ailmageService.datasetDelete(datasetDelete);
    }

    /**
     * 分类（标签）删除API
     */
    @PostMapping("/labelDelete")
    public JsonResult labelDelete(@RequestBody LabelDeleteDto labelDelete){
        return ailmageService.labelDelete(labelDelete);
    }


    /**
     * =====================图片物体检测
     */

    /**
     *  图片分组检查
     * @return
     */
    @GetMapping("/payDetection")
    public JsonResult payDetection(List<MultipartFile> files ,@RequestParam(name = "threshold",defaultValue = "0.8") String threshold){
        return ailmageService.payDetection(files,threshold);
    }


}
